package czk.concrent.lockSupport;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * lockSupport练习
 *
 * @Author:ChenZhangKun
 * @Date: 2021/5/12 22:39
 */
public class LockSupportDemo {
    public static void main(String[] args) throws InterruptedException {
        // 调用
        Thread t1=new Thread(()->lock());
        t1.start();
        // 休息后再解锁
        TimeUnit.SECONDS.sleep(3);
        // 解锁
        LockSupport.unpark(t1);
    }

    public static void lock() {
        // 打印
        System.out.println("锁住前");
        LockSupport.park();
        System.out.println("解锁了");
    }
}
